package com.example.administrator.myapplication;

import android.graphics.Color;
import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import static android.graphics.Color.BLUE;

public class MainActivity extends AppCompatActivity {
    SwipeRefreshLayout mSwipeRereshlayout;



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mSwipeRereshlayout =findViewById(R.id.main);
        mSwipeRereshlayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
               mSwipeRereshlayout.setBackgroundColor(Color.BLUE);
               new Thread(new Runnable() {
                   @Override
                   public void run() {
                       try {
                           Thread.sleep(5000);
                           runOnUiThread(new Runnable() {
                               @Override
                               public void run() {
                                   mSwipeRereshlayout.setRefreshing(false);

                               }
                           });
                       } catch (InterruptedException e) {
                           e.printStackTrace();
                       }


                   }
               }).start();


            }
        });



    }
}
